package app.fugema.shop.main.goods.adapter;

import com.base.common.model.bean.ADInfo;
import com.base.common.utils.DensityUtil;
import com.base.common.view.adapter.MyLinearLayoutManager;
import com.base.common.view.adapter.ada.BaseRVAdapter;
import com.base.common.view.adapter.ada.SingleRecyclerAdapter;
import com.base.common.view.adapter.bean.HeaderBean;
import com.base.common.view.adapter.connector.BaseItemMultiType;
import com.base.common.view.adapter.connector.BaseViewHolder;
import app.fugema.shop.R;
import app.fugema.shop.databinding.SeckillPrecinctTopTodayBinding;
import app.fugema.shop.databinding.SeckillPrecinctTopTodayItemBinding;

import java.util.ArrayList;
import java.util.List;

/**
 * 今日秒杀
 */
public class SeckillPrecinctTopTodayItemMultiType extends BaseItemMultiType<HeaderBean, SeckillPrecinctTopTodayBinding> {

    @Override
    public int getLayoutId() {
        return R.layout.seckill_precinct_top_today;
    }

    @Override
    public int getItemViewType() {
        return TYPE_HEAD_THREE;
    }

    @Override
    public void onCreateViewHolder(SeckillPrecinctTopTodayBinding binding, BaseViewHolder viewHolder) {
        super.onCreateViewHolder(binding, viewHolder);
        binding.rvRecyclerView.setLayoutManager(new MyLinearLayoutManager(viewHolder.itemView.getContext(), 0, false));
        binding.rvRecyclerView.setAdapter(new SingleRecyclerAdapter<ADInfo, SeckillPrecinctTopTodayItemBinding>() {
            @Override
            public int getLayoutId() {
                return R.layout.seckill_precinct_top_today_item;
            }

            @Override
            public void onBindViewHolder(SeckillPrecinctTopTodayItemBinding binding, int position, ADInfo bean) {
                super.onBindViewHolder(binding, position, bean);
                binding.tvTime.setText(bean.getImageName());
                if (position == 0) {
                    binding.tvTime.setTextColor(0xffFF7E11);
                    binding.tvTextView1.setText("抢购中");
                    binding.tvTextView1.getDelegate().setBackgroundColor(0xffFF7E11);
                    binding.tvTextView1.setTextColor(0xffffffff);
                    binding.tvTextView1.getDelegate().setIsRadiusHalfHeight(true);
                    binding.tvTextView1.setPadding(DensityUtil.getDimens(R.dimen.dp_5), DensityUtil.getDimens(R.dimen.dp_2), DensityUtil.getDimens(R.dimen.dp_5), DensityUtil.getDimens(R.dimen.dp_2));
                } else {
                    binding.tvTime.setTextColor(0xff333333);
                    binding.tvTextView1.setText("即将开始");
                    binding.tvTextView1.setTextColor(0xff333333);
                    binding.tvTextView1.getDelegate().setBackgroundColor(0);
                    binding.tvTextView1.getDelegate().setIsRadiusHalfHeight(false);

                    binding.tvTextView1.setPadding(DensityUtil.getDimens(R.dimen.dp_0), DensityUtil.getDimens(R.dimen.dp_2), DensityUtil.getDimens(R.dimen.dp_0), DensityUtil.getDimens(R.dimen.dp_2));
                }
            }
        });


    }

    @Override
    public void onBindViewHolder(SeckillPrecinctTopTodayBinding binding, int position, BaseViewHolder viewHolder, HeaderBean bean) {
        super.onBindViewHolder(binding, position, viewHolder, bean);
        if (binding.rvRecyclerView.getAdapter() instanceof BaseRVAdapter) {
            BaseRVAdapter rvAdapter = (BaseRVAdapter) binding.rvRecyclerView.getAdapter();

            List<ADInfo> list = new ArrayList<>();

            ADInfo adInfo1 = new ADInfo();
            adInfo1.setImageName("14:00");
            adInfo1.setCount(0);
            list.add(adInfo1);

            ADInfo adInfo2 = new ADInfo();
            adInfo2.setImageName("16:00");
            adInfo2.setCount(1);
            list.add(adInfo2);

            ADInfo adInfo3 = new ADInfo();
            adInfo3.setImageName("18:00");
            adInfo3.setCount(2);
            list.add(adInfo3);

            ADInfo adInfo4 = new ADInfo();
            adInfo4.setImageName("20:00");
            adInfo4.setCount(2);
            list.add(adInfo3);

            ADInfo adInfo5 = new ADInfo();
            adInfo5.setImageName("22:00");
            adInfo5.setCount(2);
            list.add(adInfo3);


            rvAdapter.setDataList(list);
        }
    }


}
